package com.byb.server.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 适用人群
 */
@ApiModel(description = "适用人群")
@Entity
@Table(name = "crowd")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "crowd")
public class Crowd implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 适用人群
     */
    @ApiModelProperty(value = "适用人群")
    @Lob
    @Column(name = "suit_crowd")
    private String suitCrowd;

    /**
     * 不适用人群
     */
    @ApiModelProperty(value = "不适用人群")
    @Lob
    @Column(name = "unsuit_crowd")
    private String unsuitCrowd;

    @OneToOne
    @JsonIgnore
    @JoinColumn(unique = true)
    private Product product;

    // jhipster-needle-entity-add-field - Jhipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSuitCrowd() {
        return suitCrowd;
    }

    public Crowd suitCrowd(String suitCrowd) {
        this.suitCrowd = suitCrowd;
        return this;
    }

    public void setSuitCrowd(String suitCrowd) {
        this.suitCrowd = suitCrowd;
    }

    public String getUnsuitCrowd() {
        return unsuitCrowd;
    }

    public Crowd unsuitCrowd(String unsuitCrowd) {
        this.unsuitCrowd = unsuitCrowd;
        return this;
    }

    public void setUnsuitCrowd(String unsuitCrowd) {
        this.unsuitCrowd = unsuitCrowd;
    }

    public Product getProduct() {
        return product;
    }

    public Crowd product(Product product) {
        this.product = product;
        return this;
    }

    public void setProduct(Product product) {
        this.product = product;
    }
    // jhipster-needle-entity-add-getters-setters - Jhipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Crowd crowd = (Crowd) o;
        if (crowd.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), crowd.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "Crowd{" +
            "id=" + getId() +
            ", suitCrowd='" + getSuitCrowd() + "'" +
            ", unsuitCrowd='" + getUnsuitCrowd() + "'" +
            "}";
    }
}
